package uoa.assignment.game;

import uoa.assignment.character.GameCharacter;
import uoa.assignment.character.Monster;
import uoa.assignment.character.Player;

import java.util.Arrays;
import java.util.Objects;

public class Map {

public String [][] layout;
public GameCharacter characters [] ;
 
  Map (int height, int width) {
	 this.layout=new String[height][width];
     this.characters=new GameCharacter[4];
     initialiseArray();
     characters[0]=new Player("player");
     characters[0].row=height-1;
     characters[0].column=width-1;
     characters[3] = new Monster("top left");
     characters[3].row=0;
     characters[3].column=0;
     characters[1] = new Monster("top right");
     characters[1].row=0;
     characters[1].column=width-1;
     characters[2] = new Monster("bottom left");
     characters[2].row=height-1;
     characters[2].column=0;
     // row ~ height
     for(GameCharacter ch:characters)
     {
         if(Objects.equals(ch.sayName(), "player"))
         {
            layout[ch.row][ch.column]= "*";
         }
         else
         {
             layout[ch.row][ch.column]= "%";
         }
     }

  }
  void initialiseArray()
  {
      for (String[] strings : layout) {

          Arrays.fill(strings, ".");
      }
  }
  public void printLayout() {
      for (String[] row : layout) {
          for (String cell : row) {
              System.out.print(cell);
          }
          System.out.println(); // 换行到下一行
      }
  }
//    public static void main(String[] args) {
//
//       Map map=new Map(3,4);
//       map.printLayout();
//    }
}
